import 'package:flutter/material.dart';
import './message_data.dart';
import './message_item.dart';

//聊天主页面
class MessagePage extends StatefulWidget{
  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return new MessagePageState();
  }

}

class MessagePageState extends State<MessagePage>{

  List<MessageData> messageData = [
    new MessageData(
        "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1544070910437&di=86ffd13f433c252d4c49afe822e87462&imgtype=0&src=http%3A%2F%2Fimgsrc.baidu.com%2Fforum%2Fw%3D580%2Fsign%3Debf3e26b1a4c510faec4e21250582528%2F0cf431adcbef76092781a53c2edda3cc7dd99e8e.jpg",
        "张伊曼",
        "突然的自我",
        new DateTime.now(),
        MessageType.CHAT
    ),
    new MessageData(
        "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1540403282649&di=c4f237332e6bf94546c950817699c2fd&imgtype=0&src=http%3A%2F%2Fimg5q.duitang.com%2Fuploads%2Fitem%2F201504%2F11%2F20150411H0128_PHr4z.jpeg",
        "张思思",
        "爱我的人",
        new DateTime.now(),
        MessageType.CHAT
    ),
    new MessageData(
        "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1544070910437&di=86ffd13f433c252d4c49afe822e87462&imgtype=0&src=http%3A%2F%2Fimgsrc.baidu.com%2Fforum%2Fw%3D580%2Fsign%3Debf3e26b1a4c510faec4e21250582528%2F0cf431adcbef76092781a53c2edda3cc7dd99e8e.jpg",
        "张伊曼",
        "突然的自我",
        new DateTime.now(),
        MessageType.CHAT
    ),
    new MessageData(
        "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1544070910437&di=86ffd13f433c252d4c49afe822e87462&imgtype=0&src=http%3A%2F%2Fimgsrc.baidu.com%2Fforum%2Fw%3D580%2Fsign%3Debf3e26b1a4c510faec4e21250582528%2F0cf431adcbef76092781a53c2edda3cc7dd99e8e.jpg",
        "张伊曼",
        "突然的自我",
        new DateTime.now(),
        MessageType.CHAT
    ),
    new MessageData(
        "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1544070910437&di=86ffd13f433c252d4c49afe822e87462&imgtype=0&src=http%3A%2F%2Fimgsrc.baidu.com%2Fforum%2Fw%3D580%2Fsign%3Debf3e26b1a4c510faec4e21250582528%2F0cf431adcbef76092781a53c2edda3cc7dd99e8e.jpg",
        "张伊曼",
        "突然的自我",
        new DateTime.now(),
        MessageType.CHAT
    ),
    new MessageData(
        "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1544070910437&di=86ffd13f433c252d4c49afe822e87462&imgtype=0&src=http%3A%2F%2Fimgsrc.baidu.com%2Fforum%2Fw%3D580%2Fsign%3Debf3e26b1a4c510faec4e21250582528%2F0cf431adcbef76092781a53c2edda3cc7dd99e8e.jpg",
        "张伊曼",
        "突然的自我",
        new DateTime.now(),
        MessageType.CHAT
    ),
    new MessageData(
        "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1544070910437&di=86ffd13f433c252d4c49afe822e87462&imgtype=0&src=http%3A%2F%2Fimgsrc.baidu.com%2Fforum%2Fw%3D580%2Fsign%3Debf3e26b1a4c510faec4e21250582528%2F0cf431adcbef76092781a53c2edda3cc7dd99e8e.jpg",
        "张伊曼",
        "突然的自我",
        new DateTime.now(),
        MessageType.CHAT
    ),
    new MessageData(
        "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1544070910437&di=86ffd13f433c252d4c49afe822e87462&imgtype=0&src=http%3A%2F%2Fimgsrc.baidu.com%2Fforum%2Fw%3D580%2Fsign%3Debf3e26b1a4c510faec4e21250582528%2F0cf431adcbef76092781a53c2edda3cc7dd99e8e.jpg",
        "张伊曼",
        "突然的自我",
        new DateTime.now(),
        MessageType.CHAT
    ),
    new MessageData(
        "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1544070910437&di=86ffd13f433c252d4c49afe822e87462&imgtype=0&src=http%3A%2F%2Fimgsrc.baidu.com%2Fforum%2Fw%3D580%2Fsign%3Debf3e26b1a4c510faec4e21250582528%2F0cf431adcbef76092781a53c2edda3cc7dd99e8e.jpg",
        "张伊曼",
        "突然的自我",
        new DateTime.now(),
        MessageType.CHAT
    ),
    new MessageData(
        "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1544070910437&di=86ffd13f433c252d4c49afe822e87462&imgtype=0&src=http%3A%2F%2Fimgsrc.baidu.com%2Fforum%2Fw%3D580%2Fsign%3Debf3e26b1a4c510faec4e21250582528%2F0cf431adcbef76092781a53c2edda3cc7dd99e8e.jpg",
        "张伊曼",
        "突然的自我",
        new DateTime.now(),
        MessageType.CHAT
    ),
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      //构造列表
      body: ListView.builder(
          //传入数据长度
          itemCount: messageData.length,
          itemBuilder: (BuildContext context,int index){
            return new MessageItem(messageData[index]);
          }
      ),
    );
  }

}